<html>
	<head></head>
	<body>
		<a id="snd" href="javascript:void(0)">Send Message</a>
		<form name="form">
			<input type="text" id="msg"/>
		</form>
		<div id="console" style="width:150px;height:50px;float:left;position: relative;overflow: hidden;"></div>
		<div id="chat" style="width:300px;float:left;"></div>
		
		<script type="text/javascript" src="plugin/jquery/jquery-1.5.2.min.js"></script>
		<script type="text/javascript" src="plugin/stomp/stomp.js"></script>
		<script type="text/javascript">
			if(!("WebSocket" in window)){
				alert("WebSocket not supported");
			}
			$(function(){
				var url = "ws://localhost:61614";
				var client = Stomp.client(url);
				client.debug = function(str){
					$("#console").append("<p>" + str + "</p>");
				};				
				var onConnect = function(){
					$("#console").append("<p>Connected</p>")
					client.subscribe("/topic/chat", function(message){
						$("#chat").append("<p>" + message.body + "</p>");
					});
				};
				var onError = function(error){
					$("#console").append("<p>Failed to connect</p>");
					$("#console").append(error);
				};
				
				client.connect('guest', 'guest', onConnect, onError);
								
				$("#snd").click(function(){
					var msg = $("#msg");
					client.send("/topic/chat", {priority: 9}, msg.val());
				});			
			})
		</script>
	</body>
</html>